package com.cole.gx095.Repository;

import com.cole.gx095.entity.Purchasebill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface PurchasebillRepository extends JpaRepository<Purchasebill,Integer>, JpaSpecificationExecutor<Purchasebill> {

    @Query(value = "select * from purchasebill pb where pb.contractNum = ?1", nativeQuery = true)
    List<Purchasebill> findAllBycontractNum(String contractNum);

    @Query(value = "select sum(billAccount) from purchasebill pb where pb.contractNum = ?1 ",nativeQuery = true)
    Double sumAmountBycontractNum(String contractNum);

    @Query(value = "select * from purchasebill pb where pb.billNum = ?1", nativeQuery = true)
    Purchasebill findoneBybillNum(String billNum);
}
